using System;
using System.Collections.Generic;
using System.Text;

using Deepcode.Flux.Core.Services.Security;
using Deepcode.Flux.Core.Systems.Audit;

namespace Deepcode.Flux.Core.Systems.Audit.Quick
{
	public class QuickAudit
	{
		private static string ProcessMessage(BaseAuditUser u, string Message)
		{
			return String.Format("{0}({1}) {2}",
					u.UserName,
					u.UserID,
					Message);
		}
		/// <summary>
		/// Raises a trace level application event
		/// </summary>
		/// <param name="u"></param>
		/// <param name="Class"></param>
		/// <param name="App"></param>
		/// <param name="Message"></param>
		/// <param name="args"></param>
		public static void RaiseTrace(BaseAuditUser u, string Class, string App, string Message, params object[] args)
		{
			string ProcessedMessageFormat = ProcessMessage(u, Message);

			SystemEvents ev = new SystemEvents();
			ev.Raise(EventSeverity.Trace, u.UserID, Class, App, ProcessedMessageFormat, args);
		}
		/// <summary>
		/// Raises an information level application event
		/// </summary>
		/// <param name="u"></param>
		/// <param name="Class"></param>
		/// <param name="App"></param>
		/// <param name="Message"></param>
		/// <param name="args"></param>
		public static void RaiseInformation(BaseAuditUser u, string Class, string App, string Message, params object[] args)
		{
			string ProcessedMessageFormat = ProcessMessage(u, Message);

			SystemEvents ev = new SystemEvents();
			ev.Raise(EventSeverity.Information, u.UserID, Class, App, ProcessedMessageFormat, args);
		}
		/// <summary>
		/// Raises an important application event
		/// </summary>
		/// <param name="u"></param>
		/// <param name="Class"></param>
		/// <param name="App"></param>
		/// <param name="Message"></param>
		/// <param name="args"></param>
		public static void RaiseImportant(BaseAuditUser u, string Class, string App, string Message, params object[] args)
		{
			string ProcessedMessageFormat = ProcessMessage(u, Message);

			SystemEvents ev = new SystemEvents();
			ev.Raise(EventSeverity.Important, u.UserID, Class, App, ProcessedMessageFormat, args);
		}
		/// <summary>
		/// Raises a critical level application event
		/// </summary>
		/// <param name="u"></param>
		/// <param name="Class"></param>
		/// <param name="App"></param>
		/// <param name="Message"></param>
		/// <param name="args"></param>
		public static void RaiseCritical(BaseAuditUser u, string Class, string App, string Message, params object[] args)
		{
			string ProcessedMessageFormat = ProcessMessage(u, Message);

			SystemEvents ev = new SystemEvents();
			ev.Raise(EventSeverity.Critical, u.UserID, Class, App, ProcessedMessageFormat, args);
		}
		/// <summary>
		/// Raises an error level application event
		/// </summary>
		/// <param name="u"></param>
		/// <param name="Class"></param>
		/// <param name="App"></param>
		/// <param name="Message"></param>
		/// <param name="args"></param>
		public static void RaiseError(BaseAuditUser u, string Class, string App, string Message, params object[] args)
		{
			string ProcessedMessageFormat = ProcessMessage(u, Message);

			SystemEvents ev = new SystemEvents();
			ev.Raise(EventSeverity.Error, u.UserID, Class, App, ProcessedMessageFormat, args);
		}
	}
}
